#!/usr/bin/env python
# -*- encoding:utf-8 -*-
#**
#-------------------------------------------------------------------------------
#[Subject   -- SQL_Gen]
#[Author    -- tianxu.xxf]
#[Created   -- 2010.9.19]
#[Updated   -- ]
#[UpAuthor  -- ]
#-----------------------------------------------------------------------------*#
from Condition import Condition
from Const._OrderType import DESC,ASC
from Const._Operator import EQ,NEQ,LT,LE,GT,GE

class Column:
    """"""
    
    def __init__(self,name='',alias=''):
        self.__name  = name
        self.__alias  = alias
        self.__arrays = []
        self.__order_type = ASC

    def __str__(self):
        if self.__alias != '':
            return self.__name + ' AS ' + self.__alias
        elif self.__name != '':
            return self.__name
        else:
            return ''

    def DESC(self):
        column = Column(self.__name,self.__alias)
        column._Column__order_type = DESC
        return column

    def ASC(self):
        column = Column(self.__name,self.__alias)
        column._Column__order_type = ASC
        return column

    def AS(self,alias):
        column = Column(self.__name,alias)
        return column

    def __eq__(self, item):
        return Condition(self,EQ,item)

    def __ne__(self, item):
        return Condition(self,NEQ,item)

    def __lt__(self, item):
        return Condition(self,LT,item)

    def __le__(self, item):
        return Condition(self,LE,item)

    def __gt__(self, item):
        return Condition(self,GT,item)

    def __ge__(self, item):
        return Condition(self,GE,item)
        
